package net.xo68.destiny.contract.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * 响应实例
 * @author wuxie
 * @version 2020-10-26
 */
@ApiModel("响应实体")
public class RespondEntity implements Serializable {
    /**
     * 成功
     */
    public static final int SUCCESS = 200;
    /**
     * 失败
     */
    public static final int FAIL = 500;
    /**
     * 成功默认消息
     */
    public static final String SUCCESS_MESSAGE = "success";
    /**
     * 失败默认消息
     */
    public static final String FAIL_MESSAGE = "fail";

    /**
     * 响应状态
     */
    @ApiModelProperty("响应状态")
    private int state;
    /**
     * 响应消息
     */
    @ApiModelProperty("响应消息")
    private String message;

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @JsonIgnore
    public boolean isSuccess(){
        return state==SUCCESS;
    }

    @JsonIgnore
    public boolean isFail(){
        return state==FAIL;
    }

    @Override
    public String toString() {
        return "RespondEntity{" +
                "state=" + state +
                ", message='" + message + '\'' +
                '}';
    }
}
